package com.wtwd.campus.service.impl;

import com.wtwd.campus.dao.RolePermissionMapper;
import com.wtwd.campus.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author mjy
 * @date 2021/06/08
 * @description
 */
@Service
public class RolePermissionServiceImpl implements RolePermissionService {
    @Autowired
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public List<Map<String, Object>> getRolePermissionList(Integer roleId) {
        //获取所有菜单
        List<Map<String, Object>> userPermissionList = rolePermissionMapper.getRolePermissionList(roleId);
        if (userPermissionList != null && userPermissionList.size() > 0) {
            for (Map<String, Object> map : userPermissionList) {
                if (map.containsKey("user_permission_id")) {
                    map.put("has_permission", true);
                } else {
                    map.put("has_permission", false);
                }
            }
        }
        //构建菜单结果集
        return userPermissionList;
    }

}
